package com.pjedu.springbootredis.web;

import com.pjedu.springbootredis.entity.User;
import com.pjedu.springbootredis.service.UserService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Author 汪洋
 * @Description
 */
@RestController
public class UserController {
    @Resource
    private UserService userService;

    @GetMapping("user")
    public Object findAll(){
        return userService.findAll();
    }

    @PostMapping("login")
    public Object login(@RequestBody User user){
        return userService.login(user);
    }

    @GetMapping("user/{uid}")
    public Object findById(@PathVariable("uid") Integer uid){
        return userService.findById(uid);
    }

    @PostMapping("user")
    public Object insertUser(@RequestBody User user) {
        return userService.insertUser(user);
    }

    @PutMapping("user")
    public Object updateUser(@RequestBody User user) {
        return userService.updateUser(user);
    }

    @DeleteMapping("user/{uid}")
    public Object deleteUserById(@PathVariable("uid") Integer uid) {
        return userService.deleteById(uid);
    }
}
